package com.example.unisys.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.unisys.dao.CourseSaleMapper;
import com.example.unisys.entity.CourseSale;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
public class CourseSaleService extends ServiceImpl<CourseSaleMapper,CourseSale> {


    public int insert(CourseSale coursesale) {
        return baseMapper.insert(coursesale);
    }

    public int insertSelective(CourseSale courseSale) {
        return baseMapper.insertSelective(courseSale);
    }

    public int updateSale(String course_id, String main_school, String sub_school) {
        return baseMapper.updateSaleByParams(course_id, main_school, sub_school);
    }

    public Integer getByMain(String main_school, String course_id) {
        return baseMapper.getByMain(main_school, course_id);
    }

    public Integer getBySub(String main_school, String sub_school, String course_id) {
        
        return baseMapper.getBySub(main_school, sub_school, course_id);
    }

    public Integer getAllByMain(String main_school) {
        return baseMapper.getAllByMain(main_school);
    }

    public Integer getAllBySub(String main_school, String sub_school) {
        return baseMapper.getAllBySub(main_school, sub_school);
    }

    public Integer getAll() {
        return baseMapper.getAll();
    }

    public List<CourseSale> getById(String main_school, String course_id) {
        return baseMapper.getById(main_school, course_id);
    }

    public List<CourseSale> getAllById(HashMap<String,Object> map){
        return baseMapper.getAllById(map);
    }



    public List<CourseSale> getSalesBySearch(Map map) {
        return baseMapper.getSalesBySearch(map);
    }

    public List<CourseSale> getSales(Map map) {
        return baseMapper.getSales(map);
    }

    public Integer getSaleSum(Map map) {
        return baseMapper.getSaleSum(map);
    }

    public List<Map<String ,Object>> getSalesByMain(HashMap<String, Object> hs) {
        return baseMapper.getSalesByMain(hs);
    }

    public List<Map<String ,Object>> getSalesBySystem(HashMap<String, Object> hs) {
        return baseMapper.getSalesBySystem(hs);
    }

    public List<Map<String ,Object>> getSalesBySub(HashMap<String, Object> hs) {
        return baseMapper.getSalesBySub(hs);
    }

    public List<CourseSale> getSalesBlur(HashMap<String, Object> hs) {
        return baseMapper.getSalesBlur(hs);
    }

    public int getSystemSaleSum() {
        return baseMapper.selectCount(new QueryWrapper<>());
//        return baseMapper.getSystemSaleSum();
    }
}
